package MultiThread.completable;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.logging.Logger;

public class ThenCombineTest {

    private static Logger log = Logger.getLogger("test1");

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        CompletableFuture<Double> rate = CompletableFuture.supplyAsync(()-> 0.04);
        CompletableFuture<Double> ben = CompletableFuture.supplyAsync(()-> 100.0);

        CompletableFuture<Double> result = rate.thenCombineAsync(ben, (a, b) ->{
            log.info(Thread.currentThread().toString());
            return a+b;
        });

        System.out.println(result.get());

    }
}
